<?php

namespace App\Dao;

use App\Exceptions\ApiErrorException;
use EasyWeChat\Factory;
/**
 * 日志记录调用模型
 *
 * @author yh 20201215
 */
class SendDao
{
  public static send_msg(){
    $config = [
        'app_id' => 'wx3cf0f39249eb0exx',//公众号app_id
        'secret' => 'f1c242f4f28f735d4687abb469072axx',//公众号secret
        'log'    => [ //生成错误日志
                    'level' => 'debug',
                    'file' => '/tmp/esaywechat.log',
              ]
    ];
    $app = Factory::officialAccount($config);
    $app->template_message->send([
            'touser' => 'user-openid',//用户openid
            'template_id' => 'template-id',//发送的模板id
            'url' => 'https://easywechat.org',//发送后用户点击跳转的链接
            'miniprogram' => [ //与公众号绑定的小程序（选传）
                    'appid' => 'xxxxxxx',//小程序id
                    'pagepath' => 'pages/xxx',//跳转页面
            ],
            'data' => [
                'key1' => 'VALUE',
                'key2' => 'VALUE2',
                ...
            ],
        ]);
  }
}